package com.dubbo;

import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
import com.alipay.api.request.AlipayUserInfoShareRequest;
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
import com.alipay.api.response.AlipayUserInfoShareResponse;

import java.io.File;
import java.io.FileFilter;
import java.io.FilenameFilter;
import java.util.Map;

public class a {
    public static void main(String[] args) {
        try {
        AlipayClient alipayClient =  new DefaultAlipayClient( "https://openapi.alipay.com/gateway.do" ,
                "2019091967577665",
                "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCQrpGlSGFxH/04uc8eXVCNcxRvk+JsUBabOXq8hc4oXPWdO07+OE0uqdmM4/XkXxFsXepYl3jIDMn29afe+COnhPR5D/f9zNFwTMEQjF9OKbc5s0gGPTYpH8gwoNS9r53kQTNsiRuTKKh5WUkBq8tJPOSdB5rk3i/YvKMmP8AdTu0zLI3TJJHkOIM0izWJ0KumJe7p5jj7EHg0gRT75L6nBGyITxbt31+Lw+XHkEkraIsiaDXzwSpMX/W2ge6FJvFyS9rBognwPGiiNUeUtmyVoAS4XJ1JoFOpvhx0j+hr+3tihBIh/608uBoAQl4dMcW/5I797dymdW9byjaV4UVJAgMBAAECggEADK5ANaxSXgffuckPTin/lWYwtFbR0Yxzbsdq6nsPxpnfLRi1o7JrkVtxpdeVBZ8Pd+ADWiBshZwZV3vQasp01Ynho3qy0ZvR/3W6tiiXcdJWLMh515Il3RTcBucRvk5WGFtelnSt5gf6PCiHLY5REuozX0/7U3Pl3akq439S5z6R7Jrmq+96SS//IHKOGEwN0L0gOPpSJI7FK4iG+tPvapxfzg6CsNeRM3jNJX8D+veBSjXoikKRK3OmokMchOgyb9nqTydu+XdKZargkHtuWPF19uNCBqQE2rCO7XMqswb+5rvpSUYMAZv0CkomkM7qMWDYIZG8OMt9N8opdh+LAQKBgQDFQScbA2WeikCJJiEvXlNyhO4f7jq8lVWzYqpCI14ClgC39+pO2MBRy8NTDbazCd3+q0FKaHiEFOgPU7NztTcOl9/BcbdgyUIT03hBeZbRxzHL8XkzaU1igtgNLUQxpcNfHK9o3ptvCiyg82XZAdB7+Tdkjn0HJqLpnLbtoCWllQKBgQC7xTzscg6KJAdLVDjivqWY07dovSk1I18PPDFGN5ga+PT6sfvseqLiePXZZeBLhknS/C3trQRlaeIOxMdnM49Kmx6h0lW1PBdlWCFKxQSPM7K6MAPRi+jkX7RtftLWll3Rf9KFYKh251C/XjwJQO39dlF3V3gQN3TW5IpQyovL5QKBgALOHmQ/9B4BEVHh/O7ThJRIV6qUlLlB1moqqQkvv5KB15jGKcrdQj7niuuPcl2xcjrA7LjGK5CVS4eMRS0MErBecIwrtdPmiM4HX9puhDqPfqHL2VFl2ffgrHnjfujF1rVvjv8Ky2MU3fWcAILJh9F7hdIkRJrpbb+svt06Pc7RAoGAHczKw3fCiPf41GK0eH/rRhrrs8q5nH5VmtRhuZQfJsC2GIdgxQIdkbXCxtLdSv8v/jUZkOvxk6q/PrrKLr3HEv8VWHdKNO4phGL9PaGQ/K0mw1fVc08yEfSCbRJAod/RWetgXNyfP+esMALjolBUtPIvMbKHEoPKnkQ9E19h2mUCgYEAukadPOC/c5untDupl1oVELC/udQikqNSxh6VBsbIGYWkTOSbJBVeKQurA+6YskWdxAZigalwFJatnQMCsNiMWA9jDr17eUPg5P5zbDthUHLKlSGOG8HUboSigqYM7kBQ2pJ80JtJ+uJRwfBPVplkiOb4F6kkZwGOTOpvpqbiFE0=",
                "json" ,
                "UTF-8",
                "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAi1AN/GwzFulPk9gC31WuQLmTd8Dhzd4pwoWVPewKecX1CKFCmjEzsY0s4ZwPDuPpEWMWLPxy6XMejtLFe4YFJWRJKWWya6c/bhHrn7m4/vYnHWM+lqgqqWqYWbnewy/AWm1YQ+GcbHBom9j5qMmZR4MB8rXYFtcIY/z47sFpUqcdhKjs+b/4Zmj74TN/rcyuQAnYkkeED8x58KV+CPebX2C1L3EDPUCYgnb6Q37Oya/Vot5Xk2NCdqfhDX1PDbmL5L0U9gKJOd/3lr/9Ap6FyxOOPgI9/Ts3F5IfKRlAuJtdogfonLgXYGwsMr3pByyCUa69r0l89LB23NMZmJ4TJwIDAQAB",  "RSA2" );   //获得初始化的AlipayClient
        AlipaySystemOauthTokenRequest request =  new  AlipaySystemOauthTokenRequest(); //创建API对应的request类
        request.setGrantType( "authorization_code" );
        request.setCode( "e0dc587816364087ad05459f8764HX14" );
        AlipaySystemOauthTokenResponse response = null; //通过alipayClient调用API，获得对应的response类

            response = alipayClient.execute(request);
            System.out.println(response.isSuccess());
            System.out.println(response.getBody());
               AlipayUserInfoShareRequest request1 =  new  AlipayUserInfoShareRequest();
            AlipayUserInfoShareResponse response1 = alipayClient.execute(request1,response.getAccessToken());
            System.out.println(response1.getBody());
            if (response1.isSuccess()){

                System.out.println( "调用成功" );
            }
            else {
                System.out.println("调用失666败");
            }
        } catch (AlipayApiException e) {
        e.printStackTrace();
    }
    }
}
